//
//  LCEssayTableViewCell.m
//  JKFuYinProject
//
//  Created by jiukuyinyue on 2017/9/8.
//  Copyright © 2017年 LC. All rights reserved.
//

#import "LCEssayTableViewCell.h"

@interface LCEssayTableViewCell ()

@end

@implementation LCEssayTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    

    [self setupUI];
}

-(void)setupUI{
}

-(void)setModel:(BeautifulEssayModel *)model{
        _model = model;
    
    _thumbpicImageView.layer.masksToBounds = YES;
    // 设置圆角大小
    _thumbpicImageView.layer.cornerRadius = 7.0 ;
    _titleLabel.textColor = RGBColor(52, 52, 52);
    if (ScreenWidth == 414) {
        self.titleLabel.font = FONT_(19.5);
    }else
    if (ScreenWidth == 375) {
        self.titleLabel.font = FONT_(19);
    }else{
        self.titleLabel.font = FONT_(17);
    }
    NSURL *url = [NSURL URLWithString:model.imageUrl];
    _thumbpicImageView.contentMode = UIViewContentModeScaleAspectFill;
    [_thumbpicImageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"placeholder"]];
    _titleLabel.text = model.title;
    NSString *dataString = [LSZSpecialPackaging GetThePreviousTime1970:model.update];
    dataString = [LSZSpecialPackaging GetThePreviousTimeAndCompareItNow:dataString];
    
    if (model.cover.count > 2) {
        // 遍历
        for (NSInteger i = 0; i < self.imgsrcImageViews.count; i++) {
            // 循环取出里面的UIImageView
            UIImageView *imgView = self.imgsrcImageViews[i];
            // 下载图片
            [imgView sd_setImageWithURL:[NSURL URLWithString:model.cover[i]] placeholderImage:[UIImage imageNamed:@"小的默认图片"]];
            imgView.layer.masksToBounds = YES;
            // 设置圆角大小
            imgView.layer.cornerRadius = 1.0 ;

        }
    }
    if (_vImgView) {
        //视频样式
//        NSLog(@"视频样式 = ");
        [self setupAutoHeightWithBottomView:self.adddateLabel bottomMargin:15];
    }else{
        if (model.cover.count > 2) {
        }else{
            //左侧样式
            
//            NSLog(@"左侧样式 = ");
//            [self setupAutoHeightWithBottomView:self.adddateLabel bottomMargin:10];
        }
    }
    
    if (model.cover.count > 2) {
        //多张图片
//        NSLog(@"多张图片 = ");
//        [self setupAutoHeightWithBottomView:self.adddateLabel bottomMargin:15];
    }
    
    NSString *string = [NSString stringWithFormat:@"%@赞    %@评    %@    %@浏览",model.praiseNum,model.commentNum,dataString,[self browseNumViews:_model.browseNum]];
    _adddateLabel.text = string;
    _adddateLabel.textColor = RGBColor(166, 166, 166);
}

-(void)layoutSubviews{
    [super layoutSubviews];
    [_adddateLabel sizeToFit];
}

#pragma mark - 浏览次数 转万  保留1位小数
- (NSString *)browseNumViews:(NSString *)number {
    if (number.length > 4) {
        //万
        NSInteger numberInt = [number integerValue];
        CGFloat value;
        value = numberInt *0.0001;
        CGFloat valueChange = round(value*100)/100;
        NSString *stringValue = [NSString stringWithFormat:@"%.1f万",valueChange];
        return stringValue;
    }else{
        return number;
    }
}
@end
